<script>
import e from "../../../res/www.a9a.cn";

var a = uni.getStorageSync('COOK_U');
var app = getApp();
export default {
  name: "formDetailPayment",
  data() {
    return {
      fid: 0, // 表单Id
      formuid: 0, // 提交序号
      buyObj: {}, // 套餐信息
      color: '',
      rgbcolor: '',
      D: '',
      title: '',

    }
  },
  onLoad(a) {
    const that = this;
    if (e.ifint(a.fid)) {
      that.fid = e.ifint(a.fid) ? a.fid : 0;
      that.formuid = e.ifint(a.formuid) ? a.formuid : 0;
    }
    app.globalData.get_config('_ZEAI').then(function (a) {
      that.setData({
        color: app.globalData._ZEAI.color,
        rgbcolor: e.c16_rgb(app.globalData._ZEAI.color)
      });
    });
    app.globalData.get_openid().then(function (a) {
      that.init();
      that.getBuy();
    });
  },
  methods: {
    // 获取表单信息
    init: function () {
      var that = this;
      e.ifint(this.fid) ||
      uni.showModal({
        content: '参数跑路了',
        confirmColor: that.color,
        confirmText: '朕知道了',
        showCancel: false,
        success: function (a) {
          uni.navigateBack();
        }
      });
      uni.showLoading({
        title: '玩命加载中...',
        mask: true
      });
      app.globalData.ajax({
        url: 'form.php',
        data: {
          submitok: 'form_detail',
          openid: a.openid,
          fid: that.fid
        },
        success: function (a) {
          if (1 == a.flag) {
            that.setData({
              D: a.D,
              color: a.D.mbbgcolor,
              title: a.D.title,
            });
            uni.setNavigationBarTitle({
              title: that.title
            });
          } else {
            uni.showToast({
              title: a.msg,
              icon: 'none',
              mask: true
            });
          }
          uni.hideLoading();
        }
      });
    },
    // 获取的购买套餐信息
    getBuy() {
      const that = this;
      app.globalData.ajax({
        url: 'form.php',
        data: {
          submitok: 'get_form_user',
          openid: a.openid,
          fid: that.fid,
          formuid: that.formuid,
        },
        success: function (a) {
          if (1 == a.flag) {
            that.setData({
              buyObj: a.D,
            });
            uni.setStorageSync('COOK_U', {
              openid: a.D.xcx_openid,
            });
          } else {
            uni.showToast({
              title: a.msg,
              icon: 'none',
              mask: true
            });
          }
          uni.hideLoading();
        }
      });
    },
    // 购买订单
    payFn() {
      const that = this;
      app.globalData.pay({
        data: {
          submitok: 'my_vip',
          grade: that.buyObj.grade,
        }
      });
    },
    getFate() {
      uni.switchTab({
        url: '/pages/index/index4',
      })
    },

  }
}
</script>

<template>
  <view :style="'--color:' + color + ';--rgbcolor:' + rgbcolor" class="formDetailPayment">
    <view class="detailIcon">
      <text class="alyIcon-chenggong chenggong"></text>
      <view class="title">{{ title }}</view>
      <view class="text">报名登记成功</view>

      <view class="detailBnt">
        <button class="detailBnt" @tap="payFn()">在线支付购买</button>

        <button class="fateBnt" @tap="getFate">进入缘分大厅</button>
      </view>

    </view>


  </view>
</template>

<style lang="scss" scoped>
@import "formDetailPayment.scss";
</style>